{/* Copyright 2020 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License. */}

import {Layout} from '@react-spectrum/docs';
export default Layout;

import docs from 'docs:@react-spectrum/image';
import {HeaderInfo, PropTable, PageDescription} from '@react-spectrum/docs';
import packageData from '@react-spectrum/image/package.json';

```jsx import
import {Flex} from '@react-spectrum/layout';
import {Image} from '@react-spectrum/image';
```

---
category: Content
---

# Image

<PageDescription>{docs.exports.Image.description}</PageDescription>

<HeaderInfo
  packageData={packageData}
  componentNames={['Image']}
  since="3.0.0" />

## Examples

```tsx example
<Image src="https://i.imgur.com/Z7AzH2c.png" alt="Sky and roof" />
```

## Content

The `Image` component represents an image within a Spectrum container
such as a [Dialog](Dialog.html). `Image` provides no specific styling
by itself, but receives styling from the parent container. In addition,
`Image` will be automatically placed within the container's layout
according to Spectrum guidelines.

**Note: Images must have an `alt` attribute.** If the image is
considered decorative and should not be announced by screen readers,
then set `alt=""` to suppress the warning.

See [Dialog](Dialog.html#examples) for examples of how to use the
`Image` component in the context of a Spectrum container.

### Internationalization

To internationalize an `Image`, a localized string should be passed to the `alt` prop.

## Props

<PropTable component={docs.exports.Image} links={docs.links} />

## Visual options

### Decorative

```tsx example
<Flex width="200px">
  <Image src="https://i.imgur.com/c3gTKSJ.jpg" alt="" />
</Flex>
```

### Object Fit

```tsx example
<Flex width="100%" height="200px">
  <Image
    src="https://i.imgur.com/c3gTKSJ.jpg"
    alt="Eiffel Tower at sunset"
    objectFit="cover" />
</Flex>
```
